feat: Add DON ID type validation and Rev Orgs service (CUSS-396, CUSS-397)#207
Conversation
CUSS-396: Add DON ID type validation with helpful error messages - Create src/devrev_mcp/utils/don_id.py with parse_don_type and validate_don_id - Integrate validation into all 14 MCP tool files (_get, _update, _delete ops) - Provides clear error messages when wrong ID type is used (e.g. rev_org ID passed to accounts_get) with tool suggestions CUSS-397: Add Rev Orgs (revenue organizations) service - Create Rev Orgs Pydantic v2 models (RevOrg, RevOrgSummary, request/response) - Implement sync RevOrgsService and async AsyncRevOrgsService - Register services in DevRevClient and AsyncDevRevClient - Create MCP tools: list, get, create, update, delete - 41 new unit tests (22 for DON ID validation, 19 for Rev Orgs) - All 1091 tests pass
🤖 Augment PR SummarySummary: This PR improves DevRev MCP tooling ergonomics by validating DON ID object types up-front and adds first-class support for Rev Orgs (revenue organizations) in both the SDK and MCP layer. Changes:
🤖 Was this summary useful? React with 👍 or 👎 |
| Args: | ||
| id: The rev org ID. | ||
| """ | ||
| validate_don_id(id, "revo", "devrev_rev_orgs_get") |
There was a problem hiding this comment.
src/devrev_mcp/tools/rev_orgs.py:68 validate_don_id() can raise ValueError, but this call happens outside the try that converts errors into RuntimeError, so users may see an unformatted exception instead of the usual MCP-friendly message.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
There was a problem hiding this comment.
Fixed in 6c39d01. Changed validate_don_id() to raise RuntimeError instead of ValueError, so the exception is now caught by the existing except ... RuntimeError blocks in all MCP tool handlers. This fixes the issue across all 40+ call sites without needing to modify any individual tool file.
| def sample_rev_org_data() -> dict[str, Any]: | ||
| """Minimal Rev Org data matching the API response shape.""" | ||
| return { | ||
| "id": "don:core:dvrv-us-1:devo/1:revorgs/123", |
There was a problem hiding this comment.
tests/unit/test_rev_orgs.py:50 The fixture uses a rev org DON type segment revorgs, but the new validation/docs elsewhere use revo for rev org IDs; this mismatch could mask a real validation bug if one of these segments is incorrect.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
There was a problem hiding this comment.
Fixed in 6c39d01. Replaced all revorgs/ with revo/ in the test fixtures to match the actual DevRev DON type segment used in production IDs and in the validation logic.
…ype in tests (#207) - Changed validate_don_id to raise RuntimeError instead of ValueError so exceptions are caught by MCP tool handlers and shown as friendly messages - Fixed test fixture DON IDs from 'revorgs/' to 'revo/' to match actual DevRev DON type segments
- Bump softprops/action-gh-release from v2 to v3 (#208) - Bump actions/deploy-pages from v4 to v5 (#209) - Bump actions/github-script from v8 to v9 (#210) - Bump cryptography from 46.0.5 to 46.0.7 - security fix CVE-2026-39892, CVE-2026-34073 (#206)
Overview
This PR implements two related enhancements to improve the DevRev MCP tools and SDK:
Problem
Users were getting generic "Validation error: Bad Request" when passing the wrong type of DON ID to MCP tools (e.g., passing a rev_org ID
revo/...todevrev_accounts_getwhich expects an account IDaccount/...). Additionally, there was no way to look up rev_orgs directly.What Changed
CUSS-396: DON ID Type Validation
New file:
src/devrev_mcp/utils/don_id.pyparse_don_type(don_id)— extracts the object type segment from a DON IDvalidate_don_id(don_id, expected_types, tool_name)— soft-validates DON IDs with clear error messagesDON_TYPE_MAP— maps DON type segments to human-friendly namesTOOL_SUGGESTIONS— maps DON types to the correct MCP tool for helpful suggestionsModified: 14 MCP tool files — added
validate_don_id()calls to all_get,_update,_deleteoperations:accounts.py,articles.py,conversations.py,engagements.py,groups.py,incidents.py,links.py,parts.py,question_answers.py,slas.py,tags.py,timeline.py,users.py,works.pyExample error message:
CUSS-397: Rev Orgs Service
New files:
src/devrev/models/rev_orgs.py— Pydantic v2 models (RevOrg, RevOrgSummary, request/response models)src/devrev/services/rev_orgs.py— SyncRevOrgsServiceand asyncAsyncRevOrgsServicesrc/devrev_mcp/tools/rev_orgs.py— MCP tools (list, get, create, update, delete)Modified:
src/devrev/client.py— Addedrev_orgsproperty to both clientssrc/devrev/models/__init__.py— Exported rev_orgs modelssrc/devrev/services/__init__.py— Exported rev_orgs servicessrc/devrev_mcp/server.py— Registered rev_orgs toolsTesting
tests/unit/test_don_id_validation.py)tests/unit/test_rev_orgs.py)Deployment Notes
enable_destructive_toolsconfig flagRelated Issues
Pull Request opened by Augment Code with guidance from the PR author